package ExamSystemClient.managerSystem.studentManagement;

import ExamSystemClient.client.ClientScanner;
import ExamSystemClient.model.Student;

import java.util.List;
import java.util.Scanner;

/**
 * 增加信息
 *
 * @author huangshuxian
 */
public class AddStudent extends StudentInfoManage{

    public AddStudent(List<Student> studentInfos) {
        super(studentInfos);
    }

    @Override
    public void operate() {
        //1、提示用户输入学生信息
        System.out.println("请输入学生的学号：");
        int number = ClientScanner.getScanner().nextInt();
        if (getIndexByNumber(number) >= 0){
            System.out.println("该学号已存在！");
            return;
        }
        System.out.println("请输入学生的姓名：");
        String name = ClientScanner.getScanner().next();
        System.out.println("请输入学生的年龄");
        int age = ClientScanner.getScanner().nextInt();
        //2、将输入信息加入List
        studentInfos.add(new Student(number, name, age));
        System.out.println("增加学生信息成功！");
    }

    @Override
    public AddStudent show() {
        System.out.println("增加学生信息！");
        return this;
    }
}
